package internal

import (
	"wechat-push/config"
	"wechat-push/internal/repository"
	"wechat-push/pkg/logger"
)

// 获取每日一句

func GetQuote() (quote config.Quote, err error) {
	// 先拿配置里的每日一句
	if config.Cfg.Quote.QuoteCh != "" && config.Cfg.Quote.QuoteEn != "" {
		quote.QuoteCh = config.Cfg.Quote.QuoteCh
		quote.QuoteEn = config.Cfg.Quote.QuoteEn
		return
	}
	// 配置里面没有的话去获取词霸每日一句
	resp, err := repository.GetCiBaQuote()
	if err != nil {
		logger.Log.Error("GetCiBaQuote err :", err)
		return
	}
	quote.QuoteEn = resp.Content
	quote.QuoteCh = resp.Note
	return
}
